package designpattern.decorator.livedemo.plantext;

import java.io.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class GenerateLog {
    public static void main(String[] args) throws IOException {
        File logFile = new File("data/application.log");
        // 确保data目录存在
        logFile.getParentFile().mkdirs();

        // OutputStream out = new GZIPOutputStream(new FileOutputStream(logFile));
        OutputStream out = new FileOutputStream(logFile);
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));

        String timestamp = LocalDateTime.now()
                .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));

        for (int i = 1; i <= 200; i++) {
            writer.write(String.format("[%s] INFO: This is log line %d\n",
                    timestamp, i));
        }
        writer.close();

    }
}
